package com.hspedu.homework.homework10;

/**
 * @Author Stringzhua
 * @Date 2024/3/3 19:16
 * description:
 */
public class Doctor {
    //属性
    private String name;
    private int age;
    private String job;
    private String gender;
    private double sal;
    //方法

    //构造器
    public Doctor(String name, int age, String job, String gender, double sal) {
        this.name = name;
        this.age = age;
        this.job = job;
        this.gender = gender;
        this.sal = sal;
    }
    //get/set方法

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }

    //    重写父类Object类的equals方法
    //并判断测试类中创建的两个对象的属性是否相等
    //即判断属性是否相同
    public boolean equals(Object obj) {
        //判断两个比较对象是否相同
        if (this == obj) {
            return true;
        }
        //判断obj是否是Doctor类型或者其子类
        //过关斩将的校验方式
        if (!(obj instanceof Doctor)) {
            //不是的话
            return false;
        }
        //向下转型,因为obj的运行类型是Doctor或者是其子类型
        Doctor doctor = (Doctor) obj;
        return this.name.equals(doctor.name) && this.age == doctor.age && this.gender == doctor.gender && this.job.equals(doctor.job) &&
                this.sal == doctor.sal;
    }
}
